package com.tjsinfo.tjsoa.system.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.system.bo.ISystemUserDutyBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUserDuty;

/**
 * 查询用户职位
 * @author Administrator
 *
 */
public class SelectUserDutyAction extends Action{
	private ISystemUserDutyBo systemUserDutyBo;

	public ISystemUserDutyBo getSystemUserDutyBo() {
		return systemUserDutyBo;
	}

	public void setSystemUserDutyBo(ISystemUserDutyBo systemUserDutyBo) {
		this.systemUserDutyBo = systemUserDutyBo;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		Integer userid = Integer.parseInt(request.getParameter("userid"));
		JSONArray array = new JSONArray();
		List<TSystemUserDuty> list = systemUserDutyBo.selectByUserId(userid);
		for (TSystemUserDuty systemUserDuty : list) {
			JSONObject object = new JSONObject(systemUserDuty);
			array.put(object);
		}
		response.getWriter().print(array);
		return null;
	}
	
	
}
